package com.coordinate.servlets;

import com.coordinate.services.CoordMailService;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class TwilioXmlVmServeServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		System.out.println("Echo'ing Request from twilio Voice Message Servlet: "+req.toString());
		
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {
		PrintWriter out = resp.getWriter();
		resp.setContentType("text/xml");
		String lVmKey = req.getParameter("vm_key");
		
		out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
		out.write("<Response> ");
		out.write("<Say>A Message from the Ministry of Sociall Affairs. United Arab Emirates.</Say>");
		out.write("<Play>http://egov-innovations.appspot.com/GetVm.wav?vm_key="+lVmKey+"</Play>");
		out.write("</Response>");
		
		out.close();
	}
}

